package com.charging.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.charging.common.annotation.Log;
import com.charging.common.core.controller.BaseController;
import com.charging.common.core.domain.AjaxResult;
import com.charging.common.enums.BusinessType;
import com.charging.system.domain.KxSystemInfo;
import com.charging.system.service.IKxSystemInfoService;
import com.charging.common.utils.poi.ExcelUtil;
import com.charging.common.core.page.TableDataInfo;

/**
 * 平台设置Controller
 *
 * @author charging
 * @date 2024-04-20
 */
@RestController
@RequestMapping("/system/system_info")
public class KxSystemInfoController extends BaseController
{
    @Autowired
    private IKxSystemInfoService kxSystemInfoService;

    /**
     * 查询平台设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:system_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(KxSystemInfo kxSystemInfo)
    {
        startPage();
        List<KxSystemInfo> list = kxSystemInfoService.selectKxSystemInfoList(kxSystemInfo);
        return getDataTable(list);
    }

    /**
     * 导出平台设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:system_info:export')")
    @Log(title = "平台设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KxSystemInfo kxSystemInfo)
    {
        List<KxSystemInfo> list = kxSystemInfoService.selectKxSystemInfoList(kxSystemInfo);
        ExcelUtil<KxSystemInfo> util = new ExcelUtil<KxSystemInfo>(KxSystemInfo.class);
        util.exportExcel(response, list, "平台设置数据");
    }

    /**
     * 获取平台设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:system_info:query')")
    @GetMapping(value = "/{systemInfoId}")
    public AjaxResult getInfo(@PathVariable("systemInfoId") Long systemInfoId)
    {
        return success(kxSystemInfoService.selectKxSystemInfoBySystemInfoId(systemInfoId));
    }

    /**
     * 新增平台设置
     */
    @PreAuthorize("@ss.hasPermi('system:system_info:add')")
    @Log(title = "平台设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KxSystemInfo kxSystemInfo)
    {
        return toAjax(kxSystemInfoService.insertKxSystemInfo(kxSystemInfo));
    }

    /**
     * 修改平台设置
     */
    @PreAuthorize("@ss.hasPermi('system:system_info:edit')")
    @Log(title = "平台设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KxSystemInfo kxSystemInfo)
    {
        return toAjax(kxSystemInfoService.updateKxSystemInfo(kxSystemInfo));
    }

    /**
     * 删除平台设置
     */
    @PreAuthorize("@ss.hasPermi('system:system_info:remove')")
    @Log(title = "平台设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{systemInfoIds}")
    public AjaxResult remove(@PathVariable Long[] systemInfoIds)
    {
        return toAjax(kxSystemInfoService.deleteKxSystemInfoBySystemInfoIds(systemInfoIds));
    }
}
